package com.ls.fw.hessian;

import java.net.MalformedURLException;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.caucho.hessian.client.HessianProxyFactory;
import com.ls.fw.hessian.domain.Car;
import com.ls.fw.hessian.domain.ScriptDTO;
import com.ls.fw.hessian.service.Person;
import com.ls.fw.hessian.service.ScriptService;




/**
 * project_name :hessianEx
 * @author kexiang.cui
 * create time :2014-6-18 下午4:08:04
 * 
 */
public class main {

	 
    
	public static void main(String[] args) throws Exception {
		 String url = "http://localhost/fw_remoting_hessian/hello";   
	     HessianProxyFactory factory = new HessianProxyFactory();   
	     Person basic = (Person) factory.create(Person.class, url);   
	     Car car  = basic.getCar();
	     
	     System.out.println("Hello: " + basic.hello());   
	     System.out.println("Hello: " + car.toString());
	     test(null);
	}
      
	public static void test(String[] args) throws Exception {
		ApplicationContext context = new ClassPathXmlApplicationContext("spring-hessian-client.xml");
		ScriptService service = context.getBean(ScriptService.class);
		
		ScriptDTO script = new ScriptDTO("Groovy", "return 'Hello World'");
		Object result = service.execute(script);
		System.out.println("result:"+result);
	}
}
